﻿using Microsoft.AspNetCore.Mvc.Filters;
using System;
using System.Collections.Generic;
using System.Text;
using WebApiV2.Inteface.Log;
using WebApiV2.Utils.Log;

namespace WebApiV2.Utils.Filter
{
    public class GlobalExceptionFilter : IExceptionFilter
    {
        private readonly ILog _log;

        public GlobalExceptionFilter(ILog log)
        {
            _log = log;
        }

        public void OnException(ExceptionContext context)
        {
            _log.Error(context.Exception);

            context.ExceptionHandled = true;
        }
        
    }
}
